package com.xiyue.lenovo.eventqs;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //获取应用程序中的bn按钮
        Button bn = (Button) findViewById(R.id.bn);
        //为按钮绑定事件监听器
        bn.setOnClickListener(new NyClickerListener());
    }

    class NyClickerListener implements View.OnClickListener {
        //实现监听器类必须实现的方法，该方法将会作为事件处理器
        @Override
        public void onClick(View v) {
            EditText txt = (EditText) findViewById(R.id.txt);
            txt.setText("bn按钮被单击了！");

        }
    }
}
